package com.bao.work.work04;


import com.alibaba.fastjson.JSON;
import com.bao.work.work03.Book;
import com.bao.work.work03.Test03;
import com.fasterxml.jackson.databind.json.JsonMapper;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;

/**
 * @author baoye
 * @date 2024-08-13/19:22
 */
public class Test04 {
    public static void main(String[] args) {
        new Test03();
        List<Book> books = Test03.readXml(new File("day15/src/com/bao/work/work01/bookstore.xml"), Book.class);
        String s = JSON.toJSONString(books);
        BufferedWriter bw= null;
        try {
            bw = new BufferedWriter(new FileWriter("day15/src/com/bao/work/work04/books.json"));
            bw.write(s);
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                bw.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
